import dayjs from "dayjs";

export function changeday(date) {
    if (!date) return null;
    else {
        let day =
            (new Date(dayjs(date).format("YYYY-MM-DD")).getTime() -
                new Date(dayjs().format("YYYY-MM-DD")).getTime()) /
            24 /
            3600000;
        return day;
    }
}
export function inputday(day) {
    return parseInt(day);
}
export function blurday(day) {
    let days = "";
    if (!day) {
        return (days = dayjs().format("YYYY-MM-DD HH:mm:ss"));
    } else if (+day > 0) {
        return (days = dayjs()
            .add(day, "day")
            .format("YYYY-MM-DD HH:mm:ss"));
    } else if (+day < 0) {
        return (days = dayjs()
            .subtract(-day, "day")
            .format("YYYY-MM-DD HH:mm:ss"));
    }
}
